<template>
  <!-- prettier-ignore -->
  <el-pagination
    @size-change="handleSizeChange($event);"
    @current-change="handleCurrentChange($event);"
    :current-page="page.current"
    :page-sizes="page.sizes"
    :page-size="page.size"
    :layout="page.layout"
    :total="page.total">
  </el-pagination>
</template>

<script>
export default {
  name: "mix-page",
  data() {
    return {
      page: {
        current: 1,
        total: 0,
        sizes: [10, 20, 50],
        size: 10,
        layout: (() => {
          let arr = ["total", "sizes", "prev", "pager", "next", "jumper"];
          return arr.join(",");
        })(),
      },
    };
  },
  methods: {
    handleSizeChange: function (event) {
      this.page.current = 1;
      if (this._.isFunction(this.ajaxData)) {
        this.ajaxData();
      }
    },
    handleCurrentChange: function (event) {
      this.page.current = event;
      if (this._.isFunction(this.ajaxData)) {
        this.ajaxData();
      }
    },
  },
};
</script>

<style>
</style>